{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "1fafd7b2",
   "metadata": {},
   "outputs": [],
   "source": [
    "#导入相关包\n",
    "import pandas as pd \n",
    "import numpy as np \n",
    "import matplotlib.pyplot as plt \n",
    "from sklearn.preprocessing import StandardScaler\n",
    "from sklearn.model_selection  import train_test_split\n",
    "from sklearn import linear_model\n",
    "from sklearn.metrics import f1_score\n",
    "import pre_process"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "8cab97f0",
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.linear_model import Ridge\n",
    "from sklearn.metrics import mean_squared_error"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "e5eaf2d6",
   "metadata": {},
   "outputs": [],
   "source": [
    "#读取相关文件\n",
    "train_path = '../data/train.csv'\n",
    "test_path = '../data/test.csv'\n",
    "submit_path = '../data/车辆贷款违约预测挑战赛sample_submit.csv'\n",
    "train_data = pd.read_csv(train_path)\n",
    "test_data = pd.read_csv(test_path)\n",
    "submit_data = pd.read_csv(submit_path)\n",
    "#生成提交文件\n",
    "submit_data['customer_id'] = test_data['customer_id']\n",
    "submit_data['loan_default'] = 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "d8875cb2",
   "metadata": {},
   "outputs": [],
   "source": [
    "train_data,test_data = pre_process.fill_inf(train_data,test_data)#填补inf值\n",
    "train_data,test_data = pre_process.del_singular_feature(train_data,test_data)#删除单值属性"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "99983a25",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nan\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "D:\\tools\\conda\\envs\\ml\\lib\\site-packages\\ipykernel_launcher.py:27: RuntimeWarning: invalid value encountered in longlong_scalars\n"
     ]
    }
   ],
   "source": [
    "def find_outliers(model,X,y,sigma=3):\n",
    "    # predict y values using model\n",
    "    try:\n",
    "        y_pred = pd.Series(model.predict(X),index=y.index)\n",
    "    # if predicting fails, try fitting the model first\n",
    "    except:\n",
    "        model.fit(X,y)\n",
    "        y_pred = pd.Series(model.predict(X),index=y.index)\n",
    "    \n",
    "    # calculate residuals between the model prediction and true y values\n",
    "    resid = y - y_pred\n",
    "    mean_resid = resid.mean()\n",
    "    std_resid  = resid.std()\n",
    "    \n",
    "    # calculate z statistic, define outliers to be where |z|>sigma\n",
    "    z = (resid-mean_resid)/std_resid\n",
    "    outliers = z[abs(z)>sigma].index\n",
    "    return outliers\n",
    "\n",
    "# 通过岭回归模型找出异常值，并绘制其分布\n",
    "\n",
    "X_train = train_data.iloc[:,0:-1]\n",
    "y_train = train_data.iloc[:,-1]\n",
    "outliers = find_outliers(Ridge(),X_train,y_train)\n",
    "outlier_index = list(outliers)\n",
    "outlier_sum = np.sum(train_data.iloc[outlier_index]['loan_default'].values)\n",
    "print(outlier_sum/len(outlier_index)*100)\n",
    "train_data=train_data.drop(labels=outlier_index)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "0561f30d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nan\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "D:\\tools\\conda\\envs\\ml\\lib\\site-packages\\ipykernel_launcher.py:8: RuntimeWarning: invalid value encountered in longlong_scalars\n",
      "  \n"
     ]
    }
   ],
   "source": [
    "\n",
    "X_train = test_data.iloc[:,0:-1]\n",
    "y_train = test_data.iloc[:,-1]\n",
    "outliers = find_outliers(Ridge(),X_train,y_train)\n",
    "outlier_index = list(outliers)\n",
    "\n",
    "outlier_sum = np.sum(train_data.iloc[outlier_index]['loan_default'].values)\n",
    "print(outlier_sum/len(outlier_index)*100)\n",
    "\n",
    "test_data=test_data.drop(labels=outlier_index)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "5036460d",
   "metadata": {},
   "outputs": [],
   "source": [
    "#划分数据集\n",
    "labels = train_data['loan_default'].values\n",
    "features_scaler = train_data.drop(['loan_default'],axis=1).values\n",
    "X_train,X_test, y_train, y_test = train_test_split(features_scaler, labels, test_size = 0.2, random_state = 0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "bb621683",
   "metadata": {},
   "outputs": [],
   "source": [
    "#标准化特征值\n",
    "sc = StandardScaler()\n",
    "sc.fit(X_train)\n",
    "X_train_std = sc.transform(X_train)\n",
    "X_test_std = sc.transform(X_test)\n",
    "\n",
    "#标准化特征值(测试数据)\n",
    "sc = StandardScaler()\n",
    "sc.fit(test_data)\n",
    "test_data_std = sc.transform(test_data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "b207be90",
   "metadata": {},
   "outputs": [],
   "source": [
    "def calculate_f1(model):\n",
    "    y_pred = model.predict(X_test)\n",
    "    y_true = y_test\n",
    "    score = f1_score(y_true, y_pred, average='macro')\n",
    "    return score"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "a479f074",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "f1: 0.45146190275923864\n"
     ]
    }
   ],
   "source": [
    "#训练逻辑回归模型\n",
    "model = linear_model.LogisticRegression(n_jobs=-1)\n",
    "model = model.fit(X_train, y_train)\n",
    "print(\"f1:\",calculate_f1(model))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "e718f8a1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "model: liblinear done\n",
      "model: lbfgs done\n",
      "model: sag done\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "D:\\tools\\conda\\envs\\ml\\lib\\site-packages\\scipy\\optimize\\linesearch.py:477: LineSearchWarning: The line search algorithm did not converge\n",
      "  warn('The line search algorithm did not converge', LineSearchWarning)\n",
      "D:\\tools\\conda\\envs\\ml\\lib\\site-packages\\scipy\\optimize\\linesearch.py:327: LineSearchWarning: The line search algorithm did not converge\n",
      "  warn('The line search algorithm did not converge', LineSearchWarning)\n",
      "D:\\tools\\conda\\envs\\ml\\lib\\site-packages\\scipy\\optimize\\linesearch.py:477: LineSearchWarning: The line search algorithm did not converge\n",
      "  warn('The line search algorithm did not converge', LineSearchWarning)\n",
      "D:\\tools\\conda\\envs\\ml\\lib\\site-packages\\scipy\\optimize\\linesearch.py:327: LineSearchWarning: The line search algorithm did not converge\n",
      "  warn('The line search algorithm did not converge', LineSearchWarning)\n",
      "D:\\tools\\conda\\envs\\ml\\lib\\site-packages\\scipy\\optimize\\linesearch.py:477: LineSearchWarning: The line search algorithm did not converge\n",
      "  warn('The line search algorithm did not converge', LineSearchWarning)\n",
      "D:\\tools\\conda\\envs\\ml\\lib\\site-packages\\scipy\\optimize\\linesearch.py:327: LineSearchWarning: The line search algorithm did not converge\n",
      "  warn('The line search algorithm did not converge', LineSearchWarning)\n",
      "D:\\tools\\conda\\envs\\ml\\lib\\site-packages\\scipy\\optimize\\linesearch.py:477: LineSearchWarning: The line search algorithm did not converge\n",
      "  warn('The line search algorithm did not converge', LineSearchWarning)\n",
      "D:\\tools\\conda\\envs\\ml\\lib\\site-packages\\scipy\\optimize\\linesearch.py:327: LineSearchWarning: The line search algorithm did not converge\n",
      "  warn('The line search algorithm did not converge', LineSearchWarning)\n",
      "D:\\tools\\conda\\envs\\ml\\lib\\site-packages\\scipy\\optimize\\linesearch.py:477: LineSearchWarning: The line search algorithm did not converge\n",
      "  warn('The line search algorithm did not converge', LineSearchWarning)\n",
      "D:\\tools\\conda\\envs\\ml\\lib\\site-packages\\scipy\\optimize\\linesearch.py:327: LineSearchWarning: The line search algorithm did not converge\n",
      "  warn('The line search algorithm did not converge', LineSearchWarning)\n",
      "D:\\tools\\conda\\envs\\ml\\lib\\site-packages\\scipy\\optimize\\linesearch.py:477: LineSearchWarning: The line search algorithm did not converge\n",
      "  warn('The line search algorithm did not converge', LineSearchWarning)\n",
      "D:\\tools\\conda\\envs\\ml\\lib\\site-packages\\scipy\\optimize\\linesearch.py:327: LineSearchWarning: The line search algorithm did not converge\n",
      "  warn('The line search algorithm did not converge', LineSearchWarning)\n",
      "D:\\tools\\conda\\envs\\ml\\lib\\site-packages\\scipy\\optimize\\linesearch.py:477: LineSearchWarning: The line search algorithm did not converge\n",
      "  warn('The line search algorithm did not converge', LineSearchWarning)\n",
      "D:\\tools\\conda\\envs\\ml\\lib\\site-packages\\scipy\\optimize\\linesearch.py:327: LineSearchWarning: The line search algorithm did not converge\n",
      "  warn('The line search algorithm did not converge', LineSearchWarning)\n",
      "D:\\tools\\conda\\envs\\ml\\lib\\site-packages\\scipy\\optimize\\linesearch.py:437: LineSearchWarning: Rounding errors prevent the line search from converging\n",
      "  warn(msg, LineSearchWarning)\n",
      "D:\\tools\\conda\\envs\\ml\\lib\\site-packages\\scipy\\optimize\\linesearch.py:327: LineSearchWarning: The line search algorithm did not converge\n",
      "  warn('The line search algorithm did not converge', LineSearchWarning)\n",
      "D:\\tools\\conda\\envs\\ml\\lib\\site-packages\\sklearn\\utils\\optimize.py:195: UserWarning: Line Search failed\n",
      "  warnings.warn('Line Search failed')\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "model: newton-cg done\n",
      "model: saga done\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<AxesSubplot:title={'center':'score change with solver'}, xlabel='solver'>"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAFBCAYAAABn1FRNAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAerklEQVR4nO3de5xVdb3/8ddb7iqa4lQK6OClkqOCiJiiWGKJl7BjJpCV9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W2Jms+9yIiLoi67LWlerCIjOryu+Bl4GHyLqatm7Ce+hm9iaSHouI/Yquw9rOB0XNrKn7JO1fdBHWdt5DN7M3kbQQ2JvsYOh6NneN4d5IuzgHupm9iXsj7b4c6GZmiXAbuplZIhzoZmaJcKCbAZLuljSy6DrMtoYD3awdSepRdA1WXg50S5ak7STNkPSIpMckTZA0VtLDkuZLuiq/zL3yOWdLurhi+HRJl+aPPynpQUnzJP2iMbwlvSLpx5IeAQ7t1BdpVsGBbikbByyPiGH5lY9/BK4GJkTE/mRdX3yuyXNuAf69YngCMFXSvvnj0RExHNgEnJrPsx3wQL6eezvqxZi1xoFuKZsPfEjShZKOIOts6qmI+Hs+/RqyO9u/ISJWAEskvV/SAOB9wF+BscBBwBxJ8/LhPfOnbSL7IDArlDvnsmRFxN8ljQCOA74H/LnKp04FTiG7UfKtERGSBFwTEec1M/+6iNjULkWbbQXvoVuyJO0GrI2I3wAXk7Vv10raO5/lU8DsZp56K3AiMIks3AHuBE6W9M582Tu3dEWlWVG8h24p2x+4WNLrZPfH/BywI3CTpJ7AHODypk+KiJckLQKGNt6KLSIW5jdKvkPSNvnyPg/4cnjrMnzpv5lZItzkYmaWCAe6mVkiHOhmZolwoJuZJcKBbmaWCAe6mVkiHOhmZolwoJuZJeL/Az4Bqw0Lh8AlAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "#logistic_regression solver\n",
    "i_list = ['liblinear','lbfgs','sag','newton-cg','saga']\n",
    "score_list = []\n",
    "for i in i_list:\n",
    "    model = linear_model.LogisticRegression(\n",
    "        solver=i,\n",
    "        max_iter=10000\n",
    "    )\n",
    "    model = model.fit(X_train, y_train)\n",
    "    score_list.append(calculate_f1(model))\n",
    "    print(\"model:\",i,\"done\")\n",
    "score_list_df =  pd.DataFrame({'solver':i_list,'score_list':score_list})\n",
    "score_list_df.plot(x='solver' ,y='score_list',title='score change with solver',kind='bar') \n",
    "#newton-cg、sag 和 lbfgs 算法只能使用 l2 正则化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "1e9f2a58",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0.45146190275923864, 0.45146190275923864, 0.45146190275923864, 0.4524149096646272, 0.4514719327116475]\n"
     ]
    }
   ],
   "source": [
    "print(score_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "af6b922d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "model: l2 done\n",
      "model: none done\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<AxesSubplot:title={'center':'score change with penalty'}, xlabel='penalty'>"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAElCAYAAADqeCmyAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAdTElEQVR4nO3de5QV5Z3u8e8j9xgvoD1nlGureEERODbNjI7GQRSMWZCzjokkowtNMqwYycRxYkSTYFZnshY65ySTMRo1CcGV0QGNY9KjGDSJenQyKg0SHUQUMIFGEhFvREVEf+ePKrTc7rYL+rLbt5/PWntR9b5v1f7VpvvZ1W/tiyICMzNL1161LsDMzLqWg97MLHEOejOzxDnozcwS56A3M0ucg97MLHEOeuuxJJ0sqbXWdXQWSXdKmvU+/Qsl/WN31rQnJIWkw2pdh5XnoDfrJhFxekTcACDpXEkP1LqmjvqgPDn1dg5661TK+OfKrAfxL2QvJOkSSZskbZO0RtIpeXsfSZdJWpf3LZc0PO87XtIySS/l/x5f2N+9kr4l6T+BV4FDJB0p6W5Jz+f38cn3qWeIpB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fvu/kvardV2pc9CbWXdaAGwDPpnfXgZ+XNOKegFP3ZhZt5G0Mv/Qvfdts87lM3oz606vSfqrXSv5G6heq2E9vYLP6M2s20gaD9wA7JqXfwGYFRGP1qyoXsBBb2bdRtIA4EzgUGB/4CWyl1c21bKu1PmdsWbWnX4OvAisADbVtpTew2f0ZtZtJP13RBxT6zp6G1+MNbPu9BtJY2tdRG/jM3oz6zaSHgcOA54m+6ybXR9TfGxNC0ucg97Muo2kkdXaI+L33V1Lb+KgNzNLnOfozcwS56A3M0ucg96sE0gaJem/8+Xxkj5a65rMdnHQm3W+8YCD3noMB731CvkZ9xOSbpS0WtJPJX1I0nGS7pO0XNJSSQfl4++VdIWkhyU9KenEwn7ul7Qivx1fcT/9gSbgLEkrJZ0l6SlJdXn/XpLW7lo36w4OeutNjgCuiYijyD4H/QLgKuDMiDiO7LPSv1UY3zciGoELgcvztmeBUyPifwJnAf9SvIOI2AHMAxZHxPiIWAz8K/A3+ZApwG8jYksXHJ9ZVf6sG+tNNkbEf+bL/wpcBhwD3C0Jsi+t3lwY/+/5v8uBUflyP+B7+acwvgkcXuJ+F5B9xss/A5/BX7Rh3cxBb71J5ZtGtgGrIuIv2xj/ev7vm7zzu/L3wB+BcWR/EW9v904jNkr6o6TJQCPvnN2bdQtP3VhvMkLSrlD/NPAgULerTVI/SUe3s4/9gM0R8RZwDtlfAZW2AftUtP2Q7K+IWyLizT09ALM94aC33mQNcIGk1cBg8vl54ApJvwVWAse3vTkA1wCz8vFHAq9UGXMPMGbXxdi8rRn4MJ62sRrwRyBYryBpFHB7rT4iV1ID8J2IOLEW92+9m+fozbqYpLnA+Xhu3mrEZ/RmZonzHL2ZWeIc9GZmiXPQm5klzkFvZpY4B72ZWeL+P4BP2I9zzCIpAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "#logistic_regression penalty\n",
    "#i_list = ['l1','l2','elasticnet','none']\n",
    "i_list = ['l2','none']\n",
    "score_list = []\n",
    "for i in i_list:\n",
    "    model = linear_model.LogisticRegression(\n",
    "        n_jobs=-1,\n",
    "        solver='newton-cg',\n",
    "        max_iter = 2000,\n",
    "        penalty=i\n",
    "    )\n",
    "    model = model.fit(X_train, y_train)\n",
    "    score_list.append(calculate_f1(model))\n",
    "    print(\"model:\",i,\"done\")\n",
    "score_list_df =  pd.DataFrame({'penalty':i_list,'score_list':score_list})\n",
    "score_list_df.plot(x='penalty' ,y='score_list',title='score change with penalty',kind='bar') "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "2cc40919",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0.3638949136283639, 0.3638172156692031]\n"
     ]
    }
   ],
   "source": [
    "print(score_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "a75ed5ad",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "f1: 0.5336289569582044\n"
     ]
    }
   ],
   "source": [
    "model = linear_model.LogisticRegression(\n",
    "        n_jobs=-1,\n",
    "        solver='newton-cg',\n",
    "        max_iter = 2000,\n",
    "        penalty='l2',\n",
    "        class_weight='balanced'\n",
    "    )\n",
    "model = model.fit(X_train_std, y_train)\n",
    "print(\"f1:\",calculate_f1(model))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "d317726d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "f1: 0.5336289569582044\n"
     ]
    }
   ],
   "source": [
    "model = linear_model.LogisticRegression(\n",
    "        n_jobs=-1,\n",
    "        solver='newton-cg',\n",
    "        max_iter = 2000,\n",
    "        penalty='l2',\n",
    "        class_weight='balanced'\n",
    "    )\n",
    "model = model.fit(X_train, y_train)\n",
    "print(\"f1:\",calculate_f1(model))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "6d0dad18",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "预测逾期人数： 3513\n"
     ]
    }
   ],
   "source": [
    "result =(model.predict(test_data_std))\n",
    "print(\"预测逾期人数：\",np.sum(result))\n",
    "submit_data['loan_default'] = result\n",
    "submit_data.to_csv('../data/submit/logisticregression.csv',index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "bbdb0c84",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "f1: 0.5336289569582044\n"
     ]
    }
   ],
   "source": [
    "print(\"f1:\",calculate_f1(model))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "61e0ae8d",
   "metadata": {},
   "outputs": [],
   "source": [
    "importance = model.coef_[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "0f73af09",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[-2.21969880e-02 -5.89104558e-02  1.06597251e-01  1.07564301e-07\n",
      "   6.82117955e-08 -2.15799461e-07 -1.09001019e-02  7.90351201e-03\n",
      "  -4.32987450e-02 -1.20114308e-07 -4.56061453e-07  5.93865383e-07\n",
      "   3.40580206e-05 -1.70727826e-05 -6.18540150e-04  6.57867762e-05\n",
      "   2.36250556e-03  1.50031671e-02 -6.40501773e-05 -1.43837282e-01\n",
      "  -1.01802592e-01  1.94628015e-03 -1.06847410e-07  2.49127900e-07\n",
      "  -1.57385386e-02  2.24658560e-01  3.32773079e-04 -3.40944503e-03\n",
      "   1.53956795e-01  1.52726912e-01 -3.30970899e-02  3.67134678e-02\n",
      "  -1.88036139e-02  1.79098539e-02  6.32985064e-02 -1.25350816e-08\n",
      "  -3.87782163e-07  3.78100582e-07  1.42276738e-07 -6.33226567e-09\n",
      "  -9.12465099e-08 -1.54599590e-07 -1.26478916e-06  7.52665746e-02\n",
      "  -1.43074056e-01 -1.88839775e-01 -1.19775335e-02]]\n"
     ]
    }
   ],
   "source": [
    "print(importance)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "40c6a06d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<BarContainer object of 47 artists>"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAD4CAYAAADvsV2wAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAAM+0lEQVR4nO3df6xf9V3H8efLsjqTZW6MhhEKu5g1MTVBll3ZjDqXUWKRhe4PtkHc7BKW/iPJjBpTJcFIYtJJ4uAP/ljDiGxRkeGPNaNKWEfi/nCTi+AckElHihQZvWxDZxYhuLd/fE/dl8u9tLffb++9/b6fj6Tp+Zzzyfl88mm/r/u5n3O+56SqkCTNvh9b7w5IktaGgS9JTRj4ktSEgS9JTRj4ktTEWevdgZWcc845NTc3t97dkKQzykMPPfR8VW1Z7tiGDfy5uTkWFhbWuxuSdEZJ8tRKx1zSkaQmDHxJasLAl6QmDHxJasLAl6QmDHxJasLAl6QmDHxJamLDfvFKmgVze+991b4j+65ch55IzvAlqQ0DX5KaMPAlqQkDX5KaMPAlqQkDX5KaMPAlqQkDX5KamErgJ9mZ5JtJDifZu8zx30ryWJKvJzmU5G3TaFeSdPImDvwkm4DbgCuA7cC1SbYvqfYwMF9VFwP3AH88abuSpNWZxgz/UuBwVT1ZVS8BdwG7xitU1QNV9YOh+FVg6xTalSStwjQC/3zg6bHy0WHfSq4D/m65A0n2JFlIsrC4uDiFrkmSjlvTi7ZJPgLMAzcvd7yq9lfVfFXNb9myZS27JkkzbxpPy3wGuGCsvHXY9wpJdgA3AL9cVS9OoV1J0ipMY4b/ILAt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EYN8uBfz7w9Fj56LCvo1W9t2CWJJkD3gF8jWbjMCxlPMLoKbb3M3oPxQtV9fJQpcNn4hbgd4Hjj2R/C/3G4P/NcuBrGTW6D7fFvbhJ3gD8FfCbVfVf48c6jENV/W9VXQJsZfQb70+vb4/WVpL3A8eq6qH17stGccLn4Z/BngEuGCtvHfZ1dFLvLZglSV7HKOz/rKr+etjdbhwAquqFJA8APw+8KclZwwx31j8TvwBcleRXgdcDbwRupdcYvMIsz/AfBLYNV+Q3A9cwen5/Ryd8b8EsGdZpPwM8XlV/MnaozTgk2ZLkTcP2TwCXM7qW8QBw9VBtpsegqn6vqrZW1Ryjz/+Xq+rXaDQGS830N22Hn+y3AJuAO6rqj9a3R6dfkr8A3svoMbDPAX8A/C1wN3Aho0dOf6iqll7YnRlJfhH4CvCv/Gjt9vcZreO3GIckFzO6ILmJ0cTu7qq6KclPMbqB4WzgYeAjVfXi+vV0bSR5L/A7VfX+rmMAMx74kqQfmeUlHUnSGANfkpow8CWpCQNfkpow8CWpCQNfkpow8CWpif8DkZ5oPKaIxGAAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "from matplotlib import pyplot\n",
    "pyplot.bar([x for x in range(len(importance))], importance)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
